@isTest
private class CMSTestClass {
   // Methods for testing
   
    public static testMethod void testTriggers(){
   
       // Start Test
       Test.startTest();
       
       // Create  a Case with Status New
       Case testCase = new Case(Status = 'New');
       // Assign the Record Type      
       testCase.RecordTypeId = [select Id from RecordType where Name = 'CMS' and SobjectType = 'Case' limit 1].Id;
               
       // insert the case and change the status values to check the Trigger
       insert testCase;       
       testCase.Status = 'Pending Acceptance';
       update testCase;       
       testCase.Status = 'Research';
       update testCase;
       testCase.Status = 'Resolution';
       
       // change the Summary Step Values to check the Summary Step Trigger
       testCase.Resolution_Letter_Status__c = 'Draft';
       testCase.Summary_Step__c = 'a';
       update testCase;
       testCase.Resolution_Letter_Status__c = 'Review';
       testCase.Summary_Step__c = 'b';
       update testCase;
       testCase.Resolution_Letter_Status__c = 'Draft';
       testCase.Summary_Step__c = 'a';
       update testCase;
       delete testCase;
       
       // Stop Test
       Test.stopTest();
    }
    
    public static testMethod void testControllers() {

        // Start Test
        Test.startTest();

        // Create instance of MyWestForm    
        PageReference pageRef = Page.MyWestForm;
        Test.setCurrentPageReference(pageRef);
        
        // Create Account for the Case
        Account newAccount = new Account (name='Testing Student');
        insert newAccount;
        Case myCase = new Case (AccountId=newAccount.id);
        insert myCase;
        
        // Add parameters and headers to the Page
        ApexPages.currentPage().getParameters().put('imsEnterprise', '<NAME>MyWest</NAME><ID>a1924</ID><GIVEN>Test</GIVEN><FAMILY>Student</FAMILY><EMAIL>aba@abctest.com</EMAIL>');
        ApexPages.currentPage().getHeaders().put('Origin','https://prod.campuscruiser.com/');

        // Define controller for the page and class
        ApexPages.StandardController sc = new ApexPages.standardController(myCase);
        ManualSubmissionForm_AC controller = new ManualSubmissionForm_AC(sc);
        
        // Access the Select Option values of the page that are referenced in the Controller
        List<SelectOption> states= controller.getstates();
        List<SelectOption> campuses= controller.getcampusLocations();
        List<SelectOption> programs= controller.getprogramDetails();
        //List<SelectOption> catalogs= controller.getCatalogNumbers();
        List<SelectOption> wasWestStudents = controller.getWestStudent();
        
        // Access the West and My West Values
        Boolean West = controller.getWest();
        Boolean MyWest = controller.getMyWest();
        
        //Case c = controller.getcaseCon();
        //CaseCon.Account.FirstName = 'Test';
        
        // Access the Object values
        controller.CaseCon = null;
        controller.CaseCon.Account.FirstName = 'Test';
        controller.CaseCon.Account.LastName = 'Student';
        controller.CaseCon.Account.External_ID_2__c = 'Test1234';
        controller.CaseCon.Account.PersonEmail = 'test@test.com';
        controller.CaseCon.Account.PersonBirthDate = date.parse('12/27/2009');
        controller.CaseCon.Account.PersonMailingStreet =  'Test Street Address\nTest Suite';
        controller.CaseCon.Account.PersonMailingCity = 'Test City';
        controller.CaseCon.Account.PersonMailingPostalCode = '12345';
        controller.CaseCon.Account.PersonHomePhone = '1233124324';
        controller.CaseCon.Account.Message_Phone__c = '1231231231';
        controller.CaseCon.Account.Work_Phone__c = '1231233212';
        controller.campus = 'Test Campus';
        controller.program = 'Test Program';
        //controller.catalog = 'Test Catalog';
        controller.state = 'Arizona';
        Controller.wasWestStudent = 'Yes';
        
        // Call Submit function 
        controller.Submit();
        
        // Stop Test
        Test.stopTest();

    }
    
    
    public static testMethod void testScheduling(){
        
        
        
        Case c1 = new Case();
        Case c2 = new Case();
        c1.Status = 'New';
        c2.Status = 'New';
        insert c1;
        insert c2;
                
        c1.Status = 'Pending Acceptance';
        c1.Status_Pending_Date__c =  datetime.newInstance(2008, 12, 1, 12, 30, 2);                      
        c2.Status = 'Research';
        c2.Status_Research_Date__c =  datetime.newInstance(2008, 12, 1, 12, 30, 2);                                            
        update c1;
        update c2;
        
        System.debug('Testing Schedule Begin $#@!');
        String jobId = System.schedule('Test Schedule Daily Updates for CMS',  '0 0 2 ? * *', new ScheduledDailyAlert());
        System.debug('Testing Schedule end $#@!');    
    }
    
    public static testMethod void testSchedulingHoliday(){
    
        // Start Test
        Test.startTest();
        
        // add Today as Holiday
        //addTodayasHoliday();
        
        System.debug('Testing Schedule Begin !@#$');
        String jobId = System.schedule('Test Schedule Daily Holiday for CMS',  '0 0 1 ? * *', new ScheduledDailyAlert());
        System.debug('Testing Schedule end !@#$');
        
        // Stop Test
        Test.stopTest();
    }
    
    
    // Adding Today as holiday for testing
    public static void addTodayasHoliday(){
        List<Holiday> holidayList = [select ActivityDate From Holiday];
        Holiday holiday = new Holiday();
        holiday.ActivityDate = date.newinstance(1960, 2, 17);
        holiday.Name = 'Test Holiday';
        holiday.Description = 'Used for Testing';
        holiday.isAllDay = True;
        holidayList.add(holiday);
        insert holiday;
        //upsert holidayList;
    }
 
}